import {validEmail, validTel} from './validate'

const FormValidate = (function() {
  function FormValidate() {
  }

  FormValidate.Form = () => {
    return {
      checkEmail(rule, value, callback) {
        if (!value) return callback(new Error('请输入邮箱'))
        else if (!validEmail(value)) return callback(new Error('邮箱格式不正确'))
        else callback()
      },
      checkTel(rule, value, callback) {
        if (!value) return callback(new Error('请输入手机号码'))
        else if (!validTel(value)) return callback(new Error('手机号码格式不正确'))
        else callback()
      }
    }
  }
  return FormValidate
}())

export { FormValidate }
